//正则验证
window.onload = function(){

    var right = document.getElementsByClassName('right');//正确提示信息
    var wrong = document.getElementsByClassName('wrong');//错误提示信息
    var email = document.getElementsByClassName("email");

    //验证邮箱
    function emailVerify(){
        var reg = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$/;
        var str = this.value;
        if(str.match(reg)==null){
         this.parentNode.children[2].style.display = "block";
         this.parentNode.children[1].style.display = 'none';
        }
        else {
         this.parentNode.children[2].style.display = "none";
         this.parentNode.children[1].style.display = 'block';
        }
    }
    email[0].onblur= emailVerify;
    email[1].onblur= emailVerify;
    //验证手机号
    var phoneNum = document.getElementById("phoneNum");
        phoneNum.onblur= function(){//失去焦点
            var reg = /^1(3|4|5|7|8)\d{9}$/;
            var str = this.value;
            if(str.match(reg)==null){
             this.parentNode.children[2].style.display = "block";
             this.parentNode.children[1].style.display = 'none';
            }
            else {
             this.parentNode.children[2].style.display = "none";
             this.parentNode.children[1].style.display = 'block';
            }
        };

}